<?php
namespace Common\Controller;
use Think\Controller;
/**
 * Base基类控制器
 */
class BaseController extends Controller{
    /**
     * 初始化方法
     */
  	public function _initialize(){
		parent::_initialize();
		
		$session_admin_id=session('ADMIN_ID');
		if(!empty($session_admin_id)){
    		$auth=new \Think\Auth();
		    $rule_name=MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
		    $result=$auth->check($rule_name,$_SESSION['ADMIN_ID']);
		  
		   if(!$result){
			   $this->error('您没有权限访问');
		    }
			
		// 分配菜单数据
		$nav_data=D('AdminNav')->getTreeData('level','order_number,id');
			
		$assign=array(
			'data'=>$nav_data
			);
		//print_r($assign);
		$this->assign($assign);	
		
			 
		}else{
		    
			if(IS_AJAX){
				$this->error("您还没有登录！",U("admin/login/index"));
			}else{
				header("Location:".U("admin/login/index"));
				exit();
			}

		}
		
		
		
	}
}
